<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jspf/taglibs.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<body>
<div class="p-h-md p-v bg-white box-shadow pos-rlt ">
<div class="pull-right">
    <a class="btn btn-sm btn-default" href="/ads">返回广告列表</a>
  </div>
  <h3 class="no-margin">广告-${form.ads[0].aname} </h3>

<div class="p-md ">

<div class="panel no-border">
  </div>
<div id="detailDataDiv" class="panel no-border">
  </div>
  <div class="panel panel-default">
  <div class="panel-heading">广告列表</div>
  <table class="table table-bordered table-hover bg-white">
      <thead>
        <tr>
          <th>广告名称</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th>曝光量</th>
          <th>点击数</th>
          <th>点击率</th>
          <th>出价</th>
          <th>点击均价</th>
          <th>总花费</th>
          <th>状态</th>
        </tr>
      </thead>
      <tbody>
        </tbody><colgroup><col>
        <col width="11%">
        <col width="11%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="7%">
        </colgroup><tbody>
        <c:if test="${!empty form.ads}">
	        <c:forEach items="${form.ads }" varStatus="i" var="ad">
        <tr>
          <td>
            ${ad.aname }
          </td>
          <td>
            -
          </td>
          <td>
          	-<fmt:formatDate value="${ad.endAt }" pattern="yyyy-MM-dd"/>
          </td>
          <td>${ad.pv }</td>
          <td>${ad.pc }</td>
          <td><fmt:formatNumber value="${ad.ctr }" maxFractionDigits="3" />%</td>
          <td>￥<fmt:formatNumber value="${ad.bid/100 }" maxFractionDigits="3" /></td>
          <td>￥<fmt:formatNumber value="${ad.costPerClick }" maxFractionDigits="3" /></td>
          <td>￥<fmt:formatNumber value="${ad.cost }" maxFractionDigits="3" /></td>
          <td>
          <label class="ui-switch bg-info">
            <input type="checkbox" class="ng-valid ng-dirty" disabled checked="checked">
            <i></i>
          </label>
           <div class="text-danger-dk">在投</div>
          </td>
        </tr>
        </c:forEach>
        </c:if>
      </tbody>
    </table>
    <input type="hidden" id="crtSize" name="crtSize" value="${form.ads[0].crtSize }"/>
    <ipnut type="hidden" id="timeType" name="timeType" value="1"/>
    </div>
   </div>
</div>
<script type="text/javascript">
function handleDashboard(start,end,timeType){
	$.ajax({
		url: "/ajax/crtSize/detail",
		data: {start:start,end:end,crtSize: $("#crtSize").val(), timeType: timeType},
		success: function(res){
			$("#detailDataDiv").html(res)
		}
	})
}
$(function(){
	var timeType = $("#timeType").val();
	var start=formatDate(new Date(),1);
	var end =formatDate(new Date(),1);
	var timeType = $("#timeType").val()
	handleDashboard(start,end,timeType);
})

var formatDate= function formatDateTime(date,count){
	 var time =date.getTime()-1000*60*60*24*count;
	 var dateTime=new Date(time);
		 	var y = dateTime.getFullYear();  //年
		    var m = dateTime.getMonth() + 1;  //月
		    m = m < 10 ? ('0' + m) : m;  
		    var d = dateTime.getDate();  //日
		    d = d < 10 ? ('0' + d) : d;  
		    return y + '-' + m + '-' + d; 
	   }
</script>
</body>